package com.hhj.king.provider.cloud;

import com.hhj.king.provider.ctrl.HealthController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.Status;
import org.springframework.stereotype.Component;

/**
 * @author KING
 * @date 2018/10/9 20:25
 */
@Slf4j
@Component
public class MyHealthIndicator implements HealthIndicator {
    @Override
    public Health health() {
        log.info("HealthIndicator健康自查接口 ... 即将执行:{}操作", HealthController.canVisitDb);
        if (HealthController.canVisitDb) {
            return new Health.Builder(Status.UP).build();
        } else {
            return new Health.Builder(Status.DOWN).build();
        }

    }
}
